package com.tiancheng.trade.payment.controller.admin;

import com.tiancheng.trade.commom.core.data.PageInfo;
import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.commom.core.utils.JsonUtil;
import com.tiancheng.trade.payment.service.SettleFileService;
import com.tiancheng.trade.payment.vo.admin.SettleFileQueryVo;
import com.tiancheng.trade.payment.vo.admin.res.SettleFileResVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("/admin/settleFile")
public class SettleFileAdminController {
    @Resource
    private SettleFileService settleFileService;

    /**
     * 分页查询支付流水
     *
     * @param settleFileQueryVo
     * @return
     */
    @GetMapping("/findPageList")
    public Result<PageInfo<SettleFileResVo>> findList(SettleFileQueryVo settleFileQueryVo) {
        log.info(JsonUtil.toJsonString(settleFileQueryVo));
        return Result.success(settleFileService.findList(settleFileQueryVo));
    }


    /**
     * 导出渠道支付订单
     */
    @PostMapping("/exportList")
    public void exportList(@RequestBody SettleFileQueryVo settleFileQueryVo, HttpServletResponse response, HttpServletRequest request)
            throws IOException {
        settleFileService.exportList(settleFileQueryVo, response, request);
    }
}
